fix: correct StrictMetricsEvaluator::CanContainNulls/CanContainNaNs when field missing from stats map#686
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes StrictMetricsEvaluator’s handling of missing per-field entries in null_value_counts / nan_value_counts, making the evaluator conservative (i.e., assume nulls/NaNs may exist) when the stats maps are non-empty but omit the queried field, preventing incorrect kRowsMustMatch results that could skip row-level filtering.
Changes:
- Update
CanContainNullsto returntruewhen a field is absent from a non-emptynull_value_countsmap, andfalsefor required schema fields. - Update
CanContainNaNsto returntruewhen a field is absent from a non-emptynan_value_countsmap, andfalsefor non-floating-point fields. - Add regression tests for missing-entry scenarios (with one test needing adjustment to actually exercise the bug condition).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/iceberg/expression/strict_metrics_evaluator.cc |
Makes null/NaN containment checks conservative when stats maps omit a field, and adds required/non-floating fast paths. |
src/iceberg/test/strict_metrics_evaluator_test.cc |
Adds regression coverage for missing null/NaN count entries (one test currently doesn’t set bounds, so it won’t regress the original issue). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
e7344ea to
68c68b3
Compare
wgtmac
requested changes
May 28, 2026
68c68b3 to
ca30ee3
Compare
…from stats map Use Schema::FindFieldById (recursive lookup) instead of StructType::GetFieldById (top-level only). Return Result<bool> to propagate errors. Restore comment explaining null_value_counts semantics. Add regression tests in a standalone test suite.
ca30ee3 to
3c8284b
Compare
wgtmac
approved these changes
May 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
StrictMetricsEvaluator::CanContainNullsto returntrue(conservative) when a field is absent from a non-emptynull_value_countsmap, andfalsefor required fields per schemaStrictMetricsEvaluator::CanContainNaNsto returntrue(conservative) when a field is absent from a non-emptynan_value_countsmap, andfalsefor non-floating-point typesClose #685
Motivation
When
null_value_countsornan_value_countsis non-empty but does not contain an entry for the queried field, the evaluator incorrectly returnedfalse. This caused comparison operators to erroneously returnkRowsMustMatch, potentially skipping row-level filtering and returning rows that do not satisfy the predicate.Test plan